package com.yueyang.sojourn.server.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author andy.yang
 * @summary 订单状态 枚举
 * @Copyright (c) 2020, Yueyang Group All Rights Reserved.
 * @since 2020-02-13
 */
@AllArgsConstructor
public enum OrderStatusEnum implements IEnum {
    /**
     * 订单状态 枚举
     */
    TO_BE_PAY(10, "待付款"),
    TO_BE_TRIP(20, "待出行"),
    DEALED(30, "已成交"),
    CLOSED(40, "已取消"),
    REFUNDED(50, "已退款")
    ;

    @Getter
    private int code;

    @Getter
    private String desc;

    public static OrderStatusEnum ofCode(Integer code) {
        return Arrays.stream(OrderStatusEnum.values()).filter(operStatusEnum -> operStatusEnum.code == code).findFirst().orElse(null);
    }
}
